#######################
# Table 3
# Creates Table 3, comparing potential bias between total and engaged
#######################

#compute means for justified, strongly support shooter, support shooter
T3A<-svymean(~justified,nd,na.rm=TRUE)

T3B<-svymean(~SSSW,nd,na.rm=TRUE)

T3C<-svymean(~SSW,nd,na.rm=TRUE)

#compute means for only weak support, by subtracting strong from total
T3D<-T3C-T3B

#bind together
T3R1<-cbind(T3A, T3B, T3D)

#compute means for justified, support shooter, strongly support shooter
#conditional on engaged
T3E<-svymean(~justified,subset(nd,CORRECT==1),na.rm=TRUE)

T3F<-svymean(~SSSW,subset(nd,CORRECT==1),na.rm=TRUE)

T3G<-svymean(~SSW,subset(nd,CORRECT==1),na.rm=TRUE)

#compute means for only weak support, by subtracting strong from total
T3H<-T3G-T3F

#bind together
T3R2<-cbind(T3E, T3F, T3G)

#compute means for justified, support shooter, strongly support shooter
#conditional on disengaged

T3J<-svymean(~justified,subset(nd,CORRECT==0),na.rm=TRUE)

T3K<-svymean(~SSSW,subset(nd,CORRECT==0),na.rm=TRUE)

T3L<-svymean(~SSW,subset(nd,CORRECT==0),na.rm=TRUE)

#compute means for only weak support, by subtracting strong from total
T3M<-T3L-T3K

#bind together
T3R3<-cbind(T3J, T3K, T3M)

#Find bias
T3R4<-(T3R1-T3R2)/(T3R2)

#put together in one table
T3<-rbind(T3R1,T3R2,T3R3,T3R4)

#round to fit
T3<-round(T3,digits=3)


#name columns something descriptive
colnames(T3)<-c("Actions Justified","Strongly Support Shooter","Weakly Support Shooter")
  

rownames(T3)<-c("Full Sample","Engaged","Disengaged","Bias between total and engaged")

write.csv(T3,"../Main Results/T3.csv")


